if ngx.var.thumbnail_directory and ngx.var.thumbnail_directory ~= nil and ngx.var.thumbnail_directory ~= "" then
	ngx.log(ngx.ERR,"mkdir -p " .. tostring(ngx.var.thumbnail_directory))
	os.execute("mkdir -p " .. ngx.var.thumbnail_directory);
end
local command = "/usr/local/GraphicsMagick/bin/gm convert " .. ngx.var.ori_filepath .. " -resize " .. ngx.var.width .. "x" .. ngx.var.height .. " -quality 92 +profile \"*\" " .. ngx.var.thumbnail_filepath;
os.execute(command);
ngx.exec(ngx.var.newUri);
